﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class PassRecovery : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected
void btnSearchByEmail_Click(object sender, EventArgs e)
    {

        if (txtEmail.Text.Length == 0)
        {

            lblNotFound.Text =
            "Enter your email address";

            return;

        }

        string strName = Membership.GetUserNameByEmail(txtEmail.Text);

        MembershipUser user = Membership.GetUser(strName);



        if (user == null)
        {

            lblNotFound.Text =
            "User not found";

            return;

        }

        lblNotFound.Text =
        "";

        string strNewPassword = user.GetPassword(strName);

        System.Web.Mail.
        MailMessage objMail = new System.Web.Mail.MailMessage();

        objMail.Subject =
        "Here is your password";

        objMail.Body = strNewPassword;

        objMail.From =
        "protectedareas@unep-wcmc.org";

        objMail.To = user.Email;

        System.Web.Mail.
        SmtpMail.SmtpServer = "email-filter.unep-wcmc.org";

        System.Web.Mail.
        SmtpMail.Send(objMail);

    }


}
